/******************应收应付*************************//*
    Arap = function(){}
    
    Arap.init=function(subModule){

    	//Arap.loadHome(subModule);
    	 Arap.loadBoard(subModule,function(){
    		 Arap.list();
    	 });
		 
    }
    Arap.list =function(){
		var ids = $('div[id=arap_board] ul li[class=active]').attr('id');
		if(!ids){
			CM.alert("您目前还没有相关账户。<br/>请先到设置模块中添加后再回来！");
			return;
		}
		var strs= new Array(); 
		strs= ids.split(",");
		if(strs[1]=='6')Arap.receivableList(strs[0]);
		if(strs[1]=='7')Arap.payableList(strs[0]);
		if(strs[1]=='5')Credit.list(strs[0]);
		if(strs[1]=='4')Asset.list(strs[0]);
	}
    
    Arap.loadBoard=function(subModule,callback){
       var qryId=$("input[name=subjectId]").val(); //查询科目id
       $('#board').load('../arap/board.do?subModule='+subModule+rnd(),'',function(){
    	   if(callback)callback();
    	   if(qryId){
    		    Board.removeActive();
				Tab.activeLi($('li[id^='+qryId+',] a'));
			}
       });
    }
    
    Arap.goAddLend = function(oid){
    	CM.open('../arap/lend.do?method=add&subjectId='+oid+rnd(),{title:'新增借出'},function(){
    		Help.show(303,1);
		});
    }
    
    Arap.doAddLend = function(me){
        submitSave('addForm','../arap/lend.do?method=doAdd'+rnd(),function(data){ 
        	CM.close(me);
        	Arap.search();
        	Arap.loadBoard();
       });
    }
    
    Arap.doEditLend = function(me){
 	    submitSave('editForm','../arap/lend.do?method=doEdit'+rnd(),function(){    		
 	   	 CM.close(me);
 	   	 CM.afterSubmit0();
 	   	 CM.afterSubmit();
 	   	 
 	 });
 	 }
    //其他应收款
    Arap.goAddReceivable = function(oid){
    	CM.open('../arap/receivable!add.do?subjectId='+oid+rnd(),{title:'新增拖欠的收入'},function(){
    		Help.show(304,1);
		});
    }
    
    Arap.doAddReceivable = function(me){
        submitSave('addForm','../arap/receivable!doAdd.do?'+rnd(),function(data){ 
        	CM.close(me);
        	Arap.loadBoard();
        	Arap.search();
       });
    }
    
    Arap.doEditReceivable = function(me){
 	    submitSave('editForm','../arap/receivable!doEdit.do?'+rnd(),function(){ 
 	   	 CM.close(me);
 	   	 CM.afterSubmit0();
 	   	 CM.afterSubmit();	
 	 });
 	}
    
    
    //销帐/平帐
    Arap.goAddRepair = function(type){//新增平帐页面
    	tit = type=='0'? "关联相关的收款":"关联相关的付款";
    	if(rs=getCheckValue('oid','1')){
    		CM.open('../arap/repair.do?method=add&type='+type+"&oid="+rs+rnd(),{title:tit},function(){
    			if(type==0)Help.show(305,1);
    			if(type==1)Help.show(312,1);
    		});
    	}   	
    }
    
    Arap.doAddRepair = function(me,tAmount){
    	var rs=getCheckValue('pid');
    	if(Number($('#amount').val())>Number(tAmount)){
    		CM.alert("选择的金额不能大于需要平帐的金额！");
    		return false;
    	}
    	if(rs){
	        submitSave('addForm','../arap/repair.do?method=doAdd&id='+rs+rnd(),function(data){ 
	          CM.close(me);
	          Arap.loadBoard();
	          Arap.search();
	       });
        }
    }
   
    //////////////////借入//////////////////////
    
    Arap.goAddBorrow = function(oid){
    	CM.open('../arap/borrow.do?method=add&subjectId='+oid+rnd(),{title:'新增借入'},function(){
    		Help.show(310,1);
		});
    }
    
    Arap.doAddBorrow = function(me){
    	submitSave('addForm','../arap/borrow.do?method=doAdd'+rnd(),function(data){ 
         	CM.close(me);
         	Arap.loadBoard();
         	Arap.search();
        });
    }
    
    Arap.doEditBorrow = function(me){
 	    submitSave('editForm','../arap/borrow.do?method=doEdit'+rnd(),function(){    		
 	   	 CM.close(me);
 	   	 CM.afterSubmit0();
 	   	 CM.afterSubmit();	
 	 });
 	 }
    //其他应付
    Arap.goAddPayable = function(oid){
    	CM.open('../arap/payable!add.do?subjectId='+oid+rnd(),{title:'新增赊欠的支出'},function(){
    		Help.show(311,1);
    	});
    }
    
    Arap.doAddPayable = function(me){
    	submitSave('addForm','../arap/payable!doAdd.do?'+rnd(),function(){    		
    	   	 CM.close(me);
    	   	 Arap.loadBoard();
    	   	 CM.afterSubmit();	
    	 });
    }
    
    Arap.doEditPayable = function(me){
 	    submitSave('editForm','../arap/payable!doEdit.do?'+rnd(),function(){    		
 	   	 CM.close(me);
 	   	 CM.afterSubmit0();
 	   	 CM.afterSubmit();	
 	 });
 	 }
    
    Arap.doAddBorrow = function(me){
    	submitSave('addForm','../arap/borrow.do?method=doAdd'+rnd(),function(data){ 
         	CM.close(me);
         	Arap.loadBoard();
         	Arap.search();
        });
    }
    
    //批量收款
    Arap.goAddReceiptBatch=function(me){
        if(rs=getCheckValue('oid')){
    		CM.open('../arap/receiptBatch.do?method=add&oid='+rs+rnd(),{title:'新增批量收款'},function(){
    			Help.show(306,1);
    		});
    	}
    }
    
    Arap.doAddReceiptBatch = function(me){
        submitSave('addForm','../arap/receiptBatch.do?method=doAdd'+rnd(),function(data){ 
          CM.close(me);
          Arap.loadBoard();
          Arap.search();
       });
    }
    
    Arap.doEditReceiptBatch =function(me){
    	
 	   $('#edit_msg').html('正在保存，请稍候...');  
 	      submitSave('editForm','../arap/receiptBatch.do?method=doEdit'+rnd(),function(){    		
 	   		CM.close(me);
 	   	    CM.afterSubmit0();
 	   	    
 	   		CM.afterSubmit();	
 	      });
    }
    
    //收款
    Arap.goAddReceipt=function(me){
        if(rs=getCheckValue('oid',1)){
    		CM.open('../arap/receipt.do?method=add&oid='+rs+rnd(),{title:'新增收款'},function(){
    			Help.show(320,1);
    		});
    	}
    }
    
    Arap.doAddReceipt = function(me){
        submitSave('addForm','../arap/receipt.do?method=doAdd'+rnd(),function(data){ 
          CM.close(me);
          Arap.loadBoard();
          Arap.search();
       });
    }
    
    Arap.doEditReceipt =function(me){
 	   $('#edit_msg').html('正在保存，请稍候...');  
 	      submitSave('editForm','../arap/receipt.do?method=doEdit'+rnd(),function(){    		
 	   		CM.close(me);
 	   	    CM.afterSubmit0();
 	   		CM.afterSubmit();	
 	      });
    }
    

    
    //坏账
    Arap.goAddBadDebt=function(type){
    	var tit=type=='0'?'转为支出':'转为收入';
        if(rs=getCheckValue('oid','1')){
    		CM.open('../arap/badDebt.do?method=add&type='+type+"&oid="+rs+rnd(),{title:tit},function(){
    			if(type=='0')Help.show(307,1);
    			if(type=='1')Help.show(314,1);
    		});
    	}
    }
    
    Arap.doAddBadDebt = function(me){
    	$('#msg').html('正在保存，请稍候...');
        submitSave('addForm','../arap/badDebt.do?method=doAdd'+rnd(),function(data){ 
          CM.close(me);
          Arap.search();
          Arap.loadBoard();
       });
    }
    Arap.doEditBadDebt =function(me){
  	   $('#edit_msg').html('正在保存，请稍候...');  
  	      submitSave('editForm','../arap/badDebt.do?method=doEdit'+rnd(),function(){    		
  	   		CM.close(me);
  	   	    CM.afterSubmit0();
  	   		CM.afterSubmit();	
  	      }); 
     }
    
    
    
    //批量付款
    Arap.goAddPaymentBatch=function(){
        if(rs=getCheckValue('oid')){
    		CM.open('../arap/paymentBatch.do?method=add&oid='+rs+rnd(),{title:'新增批量付款'},function(){
    			Help.show(313,1);
    		});
    	}
    }
    
    Arap.doAddPaymentBatch = function(me){
    
        submitSave('addForm','../arap/paymentBatch.do?method=doAdd'+rnd(),function(data){ 
          CM.close(me);
          Arap.search();
          Arap.loadBoard();
       });
    }
    
    Arap.doEditPaymentBatch =function(me){
  	      submitSave('editForm','../arap/paymentBatch.do?method=doEdit'+rnd(),function(){    		
  	   		CM.close(me);
  	   	    CM.afterSubmit0();
  	   		CM.afterSubmit();	
  	      }); 
     }
    
    
    //付款
    Arap.goAddPayment=function(){
        if(rs=getCheckValue('oid',1)){
    		CM.open('../arap/payment.do?method=add&oid='+rs+rnd(),{title:'新增付款'},function(){
    			Help.show(321,1);
    		});
    	}
    }
    
    Arap.doAddPayment = function(me){
    
        submitSave('addForm','../arap/payment.do?method=doAdd'+rnd(),function(data){ 
          CM.close(me);
          Arap.search();
          Arap.loadBoard();
       });
    }
    
    Arap.doEditPayment =function(me){
  	      submitSave('editForm','../arap/payment.do?method=doEdit'+rnd(),function(){    		
  	   		CM.close(me);
  	   	    CM.afterSubmit0();
  	   		CM.afterSubmit();	
  	      }); 
     }
    
    
    
    
    //对冲
    Arap.goAddOffset = function(type){
    	if(rs=getCheckValue('oid','1')){
    		CM.open('../arap/offset.do?method=add&type='+type+"&oid="+rs+rnd(),{title:'应收冲应付'},function(){
    			if(type=='1'){
    				Help.show(313,1);
    			}else{
    				Help.show(308,1);
    			}
    			
    		});
        	
    	}
    }
    
    Arap.doAddOffset = function(me){
    	var rs=getCheckValue('pid')
    	if(rs){
	    	$('#msg').html('正在保存，请稍候...');
	        submitSave('addForm','../arap/offset.do?method=doAdd&id='+rs+rnd(),function(data){ 
	          CM.close(me);
	          Arap.search();
	          Arap.loadBoard();
	       });
        }
    }
    
*//**************************应收款*************************************//*
    Receivable = function(){}
    Receivable.pg = new Page("listtb");
   
    Arap.receivableList = function(subjectId){
    	if (Receivable.pg.params) {Receivable.pg.params='';}
    	url = ctx+'/arap/receivableList.jsp?';
    	if(subjectId){
    		url=url+"&subjectId="+subjectId;
    	}
    	$("#main").load(url+rnd(),function(){
    		 Help.show(301,0);
    		 $('#dataView').html(LOADING);
    		 Arap.search = Arap.searchByReceivable;
    		 Arap.searchByReceivable();
    	});
    }
    
    Arap.searchByReceivable = function(params){
    	var zone = 'dataView';
	    var form='arapSchForm';    
        url = ctx+'/arap/receivableListQry.jsp?';
        if (params) {url +=params;}
        if (Receivable.pg.params) {url +=Receivable.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){
        	Receivable.pg.query = Arap.searchByReceivable;
        	Receivable.pg.init();
        	});
    }
    
    Arap.exportByReceivable= function(){
		 submitExport('arapSchForm',ctx+'/arap/arap.do?method=exportReceivable');
	 }
    
    ReceivableAccount = function(){}
    ReceivableAccount.pg = new Page("listtb");
    Arap.receivableAccountList = function(subjectId){
    	if (ReceivableAccount.pg.params) {ReceivableAccount.pg.params='';}
    	
    	url = ctx+'/arap/arap.do?method=receivableAccountList';
    	if(subjectId){
    		url=url+"&subjectId="+subjectId;
    	}
    	$("#main").load(url+rnd(),function(){
    		 Help.show(302,0);
    		 Arap.search = Arap.searchByReceivableAccount;
    		 Arap.searchByReceivableAccount();
    	});
    }
    
    
    Arap.searchByReceivableAccount = function(params){
    	var zone = 'dataView';
	    var form='arapAccountSchForm';    
        url = ctx+'/arap/arap.do?method=receivableAccountListQry';
        if (params) {url +=params;}
        if (ReceivableAccount.pg.params) {url +=ReceivableAccount.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){
        	ReceivableAccount.pg.query = Arap.searchByReceivableAccount;
        	ReceivableAccount.pg.init();
        	});
    }
    
   
    Arap.exportByReceivableAccount= function(){
    	 submitExport('arapAccountSchForm',ctx+'/arap/arap.do?method=exportReceivableAccount');
	 }
    
    //按照人员查询
    ReceivableSummry = function(){}
    ReceivableSummry.pg = new Page("listtb");
    Arap.receivableSummry = function(subjectId){
    	if (ReceivableSummry.pg.params) {ReceivableSummry.pg.params='';}
    	url = ctx+'/arap/arap.do?method=receivableSummry&subjectId='+subjectId;
    	$("#main").load(url+rnd(),function(){
    		 Help.show(322,0);
    		 $('#dataView').html(LOADING);
    		 Arap.search = Arap.searchReceivableSummry;
    		 Arap.searchReceivableSummry();
    	});
    }
    
    Arap.searchReceivableSummry = function(params){
    	var zone = 'dataView';
	    var form='arapSchForm';    
        url = ctx+'/arap/arap.do?method=receivableSummryQry';
        if (params) {url +=params;}
        if (ReceivableSummry.pg.params) {url +=ReceivableSummry.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){
        	ReceivableSummry.pg.query = Arap.searchReceivableSummry;
        	ReceivableSummry.pg.init();
        	});
    }
    
*//**************************应付款*************************************//*
    Payable = function(){}
    Payable.pg = new Page("listtb");
    
    Arap.payableList = function(subjectId){
    	if (Payable.pg.params) {Payable.pg.params='';}
    	//url = ctx+'/arap/arap.do?method=payableList';
    	url = ctx+'/arap/payableList.jsp?';
    	if(subjectId){
    		url+="&subjectId="+subjectId;
    	}
    	$("#main").load(url+rnd(),function(){
    		Help.show(308,0);
    		$('#dataView').html(LOADING);
    		Arap.search = Arap.searchByPayable;
    		Arap.searchByPayable();
    	});
    }
    Arap.searchByPayable = function(params){
    	var zone = 'dataView';
	    var form='arapSchForm';    
        //url = ctx+'/arap/arap.do?method=payableListQry';
	    url = ctx+'/arap/payableListQry.jsp?';
        if (params) {url +=params;}
        if (Payable.pg.params) {url +=Payable.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){
        	Payable.pg.query = Arap.searchByPayable;
        	Payable.pg.init();
        	});
    }
    PayableAccount = function(){}
    PayableAccount.pg = new Page("listtb");
    Arap.payableAccountList = function(subjectId){
    	if (PayableAccount.pg.params) {PayableAccount.pg.params='';}
    	//url = ctx+'/arap/arap.do?method=payableAccountList';
    	url = ctx+'/arap/payableAccountList.jsp?';
    	if(subjectId){
    		url+="&subjectId="+subjectId;
    	}
    	$("#main").load(url+rnd(),function(){
    		Help.show(309,0);
    		$('#dataView').html(LOADING);
    		Arap.search = Arap.searchByPayableAccount;
    		Arap.searchByPayableAccount();
    	});
    }
    
    Arap.searchByPayableAccount = function(params){
    	var zone = 'dataView';
	    var form='arapAccountSchForm';    
        url = ctx+'/arap/arap.do?method=payableAccountListQry';
        if (params) {url +=params;}
        if (PayableAccount.pg.params) {url +=PayableAccount.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){
        	PayableAccount.pg.query = Arap.searchByPayableAccount;
        	PayableAccount.pg.init();
        	});
    }
    
    Arap.exportPayable= function(){
    	submitExport('arapSchForm',ctx+'/arap/arap.do?method=exportPayable');
	}
    
    Arap.exportPayableAccount= function(){
    	 submitExport('arapAccountSchForm',ctx+'/arap/arap.do?method=exportPayableAccount');
	}
    
   //按照人员查询汇总
    PayableSummry = function(){}
    PayableSummry.pg = new Page("listtb");
    Arap.payableSummry = function(subjectId){
    	if (PayableSummry.pg.params) {PayableSummry.pg.params='';}
    	url = ctx+'/arap/arap.do?method=payableSummry&subjectId='+subjectId;
    	$("#main").load(url+rnd(),function(){
    		 Help.show(323,0);
    		 $('#dataView').html(LOADING);
    		 Arap.search = Arap.searchPayableSummry;
    		 Arap.searchPayableSummry();
    	});
    }
    
    Arap.searchPayableSummry = function(params){
    	var zone = 'dataView';
	    var form='arapSchForm';    
        url = ctx+'/arap/arap.do?method=payableSummryQry';
        if (params) {url +=params;}
        if (PayableSummry.pg.params) {url +=PayableSummry.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){
        	PayableSummry.pg.query = Arap.searchPayableSummry;
        	PayableSummry.pg.init();
        	});
    }
    

 *//***********************showAll*****************//*
    
    Arap.checkAmount =function(ele){
    	var chkAmount = $(ele).parent().parent().find('#chkAmount');	
        var paidAmount = $(ele).parent().parent().find('input[name^=paidAmount]:enabled');
        if(Number(chkAmount.val())<Number(paidAmount.val())){
        	paidAmount.val(chkAmount.val());
        	CM.alert("输入金额不能大于应还/付金额!");
        	return false;
        }else{
        	return true;
         }
    }
  //计算总的收款额
    Arap.calcTotalAmount=function(ele){
       if(!Arap.checkAmount(ele)){
    	 return false;
       }
       var theTable = $(ele).parent().parent().parent();
       var ob = theTable.find('input[name^=paidAmount]:enabled');//实收金额
       var total=0;
       ob.each(function(){
          total+=Number($(this).val());
       })
       theTable.find('#amount').val(ForDight(total,2));
    }
  //计算选中的收款额
    Arap.calcTotalAmountByChecked=function(ele,amount){
        var theTable = $(ele).parents("table:first");
        var ob = theTable.find('input[name=pid][checked]:checkbox');//实收金额
        var total=0;
        ob.each(function(){
        	var v = $(this).next('input');
            total+=Number($(v).val());
        })
        if(Number(amount)<Number(total)){
        	$(ele).attr('checked','');
        	CM.alert("不能关联,选取金额的和不能大于应还/付金额:"+Number(amount));
        	return false;
        }
        theTable.find('#amount').val(ForDight(total,2));
        
     }
    


    
    
//////////////////////////信用卡/////////////////////
	function Credit(){}
	Credit.pg = new Page('listtb');//列表页面
    //查询 根据账户，明细
    Credit.search = function(params){
        url = '../arap/credit.do?method=listQry&accountId='+Credit.accountId;        
        if (Credit.pg.params) {url +=Credit.pg.params;}
        submitSearch('schForm',url+rnd(),'dataView',function(){
        	Credit.pg.init();
        }); 
                   
    } 
	
    //根据账户，明细列表   
    Credit.list = function(accountId){
        if(Credit.pg.params){Credit.pg.params=null;}
        $('#main').load('../arap/credit.do?method=list&subjectId='+accountId+rnd(),'',function(){
        	Help.show(315);
           $('#dataView').html(LOADING);         
           Credit.pg.query =Credit.search;          
           Credit.search();
           
        });
    }
    
    
    
    //导出数据
    Credit.onExport = function(){
	 	submitExport('schForm','../arap/credit.do?method=exportExl'+rnd());
    }
    
    ///////////////////资产/////////////////////
	function Asset(){}
	Asset.pg = new Page('listtb');//列表页面
    //查询 根据账户，明细
    Asset.search = function(params){
        url = '../arap/asset.do?method=listQry';        
        if (Asset.pg.params) {url +=Asset.pg.params;}
        submitSearch('schForm',url+rnd(),'dataView',function(){
        	Asset.pg.init();
        }); 
                   
    } 
	
    //根据账户，明细列表   
    Asset.list = function(accountId){
        if(Asset.pg.params){Asset.pg.params=null;}
        $('#main').load('../arap/asset.do?method=list&subjectId='+accountId+rnd(),'',function(){
           $('#dataView').html(LOADING);         
           Asset.pg.query =Asset.search;          
           Asset.search();
           Help.show(317);
        });
    }
    //导出数据
    Asset.onExport = function(){
    	submitExport('schForm','../arap/asset.do?method=exportExl'+rnd());
    }

    
    */